<template>
  <div class="address-list-bg">
      <div>
          <van-address-list v-if="addressList.length!==0" v-model="chosenAddressId" :list="addressList" @edit="onEdit" @add="onAdd" @click-item="addressChange"/>
      </div>
  </div>
</template>

<script>
export default {
  props: {
  },
  components: {
  },
  data() {
    return {
        chosenAddressId:-1,
        addressList:[],
        editState:false
    };
  },
  computed: {
  },
  watch: {
  },
  created() {
  },
  methods: {
      onAdd(){
          this.$router.replace({name:'addressAdd'})
      },
      onEdit(info){
          this.$router.replace({name:'addressEdit',params:{info:info}})
          this.editState=true
      },
      addressChange(data){
          if(!this.editState){
              this.chosenAddressId=data.id
              this.$router.back()
          }
      }
  },
};
</script>
<style scoped lang="less">
.address-list-bg{
    position: absolute;
    width: 100%;
    height: 90%;
    background: rgb(247,250,248);
}
.address-button{
    width: 95%;
    border-radius: 8px;
    .address-button-confirm{
        margin-bottom: 10px;
    }
}

</style>